package com.local.controller.admin;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.local.model.LocalBlackList;
import com.local.page.LocalBlackListPage;
import com.local.service.face.LocalBlackListService;
import com.qianhai.common.constants.CommonContans;
import com.qianhai.common.controller.BaseController;

@RestController
@RequestMapping(value = "/admin/blackList", method = RequestMethod.POST)
public class LocalBlackListController extends BaseController
{
	@Autowired
	private LocalBlackListService localBlackListService;
	
	
	/**
	 * 
	 * 方法描述：查询黑白名单列表并分页
	 * @Title: queryRotaByPage 
	 * @param @param pageInfo
	 * @param @return
	 * @return ModelMap
	 * @user zw
	 * 2015年4月7日
	 * @throws
	 */
	@RequestMapping(value = "/queryBlackListByPage.action", consumes = "application/json", produces = "application/json")
	@ResponseBody
	public ModelMap queryBlackListByPage(@RequestBody LocalBlackListPage<LocalBlackList> pageInfo)
	{
		ModelMap resultMap = new ModelMap();
		
		try
		{
			localBlackListService.queryBlackListByPage(pageInfo);
			resultMap.put(CommonContans.STRUTS_DATA, pageInfo);
			resultMap.put(CommonContans.STRUTS_RESULT,
					CommonContans.STRUTS_SUCCESS);
		} catch (Throwable e)
		{
			// 请保持所有代码一直性，没有特殊处理请使用该代码.
			this.printExction(resultMap, e);
		}
		return resultMap;
	}
	
	/**
	 * 
	 * 方法描述：增加或者更新黑白名单信息
	 * @Title: addOrModifyLocalBlackList 
	 * @param @param localBlackList
	 * @param @return
	 * @return ModelMap
	 * @user Administrator
	 * 2015年10月6日
	 * @throws
	 */
	@RequestMapping(value = "/addOrModifyLocalBlackList.action", consumes = "application/json", produces = "application/json")
	@ResponseBody
	public ModelMap addOrModifyLocalBlackList(
			@RequestBody LocalBlackList localBlackList)
	{
		ModelMap resultMap = new ModelMap();
		
		try
		{
			localBlackListService.saveOrUpdateLocalBlackList(localBlackList);
			resultMap.put(CommonContans.STRUTS_RESULT,
					CommonContans.STRUTS_SUCCESS);
		} catch (Throwable e)
		{
			// 请保持所有代码一直性，没有特殊处理请使用该代码.
			this.printExction(resultMap, e);
		}
		return resultMap;
	}
	
	/**
	 * 
	 * 方法描述：通过主键获取黑白名单的信息
	 * @Title: queryLocalBlackListById 
	 * @param @param uuid
	 * @param @return
	 * @return ModelMap
	 * @user Administrator
	 * 2015年10月6日
	 * @throws
	 */
	@RequestMapping(value = "/queryLocalBlackListById.action", consumes = "application/json", produces = "application/json")
	@ResponseBody
	public ModelMap queryLocalBlackListById(String uuid)
	{
		ModelMap resultMap = new ModelMap();
		
		try
		{
			LocalBlackList localBlackList =localBlackListService.selectByPrimaryKey(uuid);
			resultMap.put(CommonContans.STRUTS_DATA, localBlackList);
			resultMap.put(CommonContans.STRUTS_RESULT,
					CommonContans.STRUTS_SUCCESS);
		} catch (Throwable e)
		{
			// 请保持所有代码一直性，没有特殊处理请使用该代码.
			this.printExction(resultMap, e);
		}
		return resultMap;
	}
	
	/**
	 * 
	 * 方法描述：通过主键删除黑白名单人员
	 * @Title: deleteById 
	 * @param @param uuid
	 * @param @return
	 * @return ModelMap
	 * @user Administrator
	 * 2015年10月6日
	 * @throws
	 */
	@RequestMapping(value = "/deleteById.action", consumes = "application/json", produces = "application/json")
	@ResponseBody
	public ModelMap deleteById(String uuid)
	{
		ModelMap resultMap = new ModelMap();
		
		try
		{
			localBlackListService.deleteByPrimaryKey(uuid);
			resultMap.put(CommonContans.STRUTS_RESULT,
					CommonContans.STRUTS_SUCCESS);
		} catch (Throwable e)
		{
			// 请保持所有代码一直性，没有特殊处理请使用该代码.
			this.printExction(resultMap, e);
		}
		return resultMap;
	}
}
